Skip to content

3.x: add ability to add multiple optional parameters to table scopes#226

Merged
markstory merged 4 commits into3.xfrom
3.x-scope-params
Jan 12, 2023
Merged

3.x: add ability to add multiple optional parameters to table scopes#226
markstory merged 4 commits into3.xfrom
3.x-scope-params

Conversation

@LordSimal
Copy link
Copy Markdown
Contributor

Fixes #225

@LordSimal LordSimal added this to the 3.0 milestone Jan 6, 2023
* @return mixed The modified resource.
*/
public function applyScope(string $action, mixed $resource): mixed;
public function applyScope(string $action, mixed $resource, mixed ...$optionalArgs): mixed;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a breaking change as user-land code will have implemented this interface. We should add this to the documentation/migration guide.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I was just curious if you guys even like this idea or not 😄
The first version of the 3.0 migration guide has been added with the major changes I have seen via looking at 2.x...3.x-scope-params

'secondArg' => false,
])
->willReturn($query);
$result = $service->applyScope($user, 'additionalArguments', $query, 'first argument', false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will these changes also enable the use of named parameters? eg. applyScope($user, category: $category)

Copy link
Copy Markdown
Contributor Author

@LordSimal LordSimal Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a test which proves it works 😉

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants